package net.pws.oos.web.dto;

import javax.servlet.http.HttpServletRequest;

import net.pws.oos.biz.model.Organization;

@SuppressWarnings("unchecked")
public class OrganizationTreeNodeDto extends AbstractTreeNode {

	public static OrganizationTreeNodeDto from(Organization organization,
			HttpServletRequest request) {
		OrganizationTreeNodeDto result = new OrganizationTreeNodeDto();
		result.metadata.put("id", organization.getId());
		result.metadata.put("name", organization.getName());
		result.metadata.put("code", organization.getCode());
		result.metadata.put("type", "organ");
		result.setTitle(organization.getShortName());
		result.data.put("icon", request.getContextPath() + "/images/organ.png");
		// if(organization.isLeaf()) {
		// result.state = "leaf";
		// }
		return result;
	}

	public OrganizationTreeNodeDto() {
	}
}
